package com.leetcode.题库;

/**
 * @author 覃国强
 * @date 2022-05-02 14:57
 */
public class 题库_0220_存在重复元素III {

  static
  class Solution {
    public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
      for (int i = 0; i < nums.length; ++i) {
        for (int j = i + 1; j < i + k &&  j < nums.length; ++j) {
          if (Math.abs(nums[i] - nums[j]) <= t) {
            return true;
          }
        }
      }
      return false;
    }
  }

}
